<?php require_once ADMINVIEWPATH.'admin_header.php'; ?>
<?php require_once ADMINVIEWPATH.'admin_menu.php'; ?>
<!-- Page Content -->
<div class="page-content">
    <!-- Page Breadcrumb -->
    <div class="page-breadcrumbs">
        <ul class="breadcrumb">
            <li>
                <i class="fa fa-home"></i>
                <a href="#">首页</a>
            </li>
            <li class="active">
                <a href="#">站内广播</a>
            </li>
        </ul>
    </div>
    <!-- Page Body -->
    <div class="page-body">
        <div class="row">
            <div class="col-lg-12 chart-container">
                <div id="dashboard-chart-visits" class="chart chart-lg no-margin">
                    <div class="widget-body">
                            <div class="table-toolbar">
                                <a id="editabledatatable_new" href="/luckydog/broadcast/textures"  class="add btn btn-default">
                                    添加公告
                                </a>
                            </div>
                            <table class="table table-striped table-bordered table-hover" id="simpledatatable">
                                <thead>
                                    <tr>
                                        <th>id</th>
	                                    <th>标题</th>
                                        <th>发布时间</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                 <?php
                                  if (!empty($broadcastList))
                                  {
                                    foreach ($broadcastList AS $row)
                                    {
                                  ?>
                                    <tr class="gradeX ">
                                        <td class="center"><?=$row['id']?></td>
                                       <td class="center"><?=$row['title']?></td>
                                        <td class="center"><?=$row['publishtime']?date("Y-m-d H:i:s",$row['publishtime']):'--'?></td>
                                        <td  class="center " data_id="<?=$row['id']?>">
                                            <a href='javascript:void(0);'  <?php if($row['isbroadcast'] == 0){?>class="publish"<?php }?>><?php if($row['isbroadcast'] == 0){echo "发布";}else{echo "已发布";}?></a>
                                           <a href='/luckydog/broadcast/textures?id=<?=$row['id']?>'  class="edit">修改</a>
                                            <a  href='javascript:void(0);' class="poi js_del">删除</a>     
                                   </td>
                                    </tr>
                                <?php
                                    }
                                  }
                                  ?>
                                </tbody>
                            </table>
                        </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div></div></div></div></div>
<?php require_once ADMINVIEWPATH.'admin_footer.php'; ?>
<script>
    $(document).ready(function(){
        $(".js_del").click(function(){
            var id = $(this).parent().attr("data_id");
            //判断是否有子分类
            if (confirm("您确定要删除吗？")) {
                $.post("/luckydog/broadcast/delBroadcast", {id:id}, function(data) {  
                        if(data){
                            window.location.reload();    
                        }else{
                            layer.msg("删除失败");
                        }         
                        
                }, "json");
            }
            });     
//发布
        $(".publish").click(function(){
            var id = $(this).parent().attr("data_id");
            if (confirm("您确定要发布公告吗？")) {
                $.post("/luckydog/broadcast/do_publish", {id:id}, function(data) {  
                        if(data){
                            layer.msg("发布成功");
                            window.location.reload();    
                        }else{
                            layer.msg("发布失败");
                        }         
                        
                }, "json");
            }
            }); 
    });
</script>



